﻿using Deixei.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace Deixei.Web
{
    public class DeixeiApplication : HttpApplication, IRegisteredObject
    {
        public void Stop(bool immediate)
        {
            if (immediate)
            {
                HostingEnvironment.UnregisterObject(this);
            }
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();


            DependencyResolverFactory factory = new DependencyResolverFactory();
            Infrastructure.IDependencyResolver unity = factory.CreateInstance();
            unity.RegisterTypeHelper<DeixeiViewMasterPage>();
            unity.RegisterTypeHelper<DeixeiViewPage>();
            unity.RegisterTypeHelper<DeixeiViewUserControl>();
            IoC.InitializeWith(factory);
            

        }
    }
}
